# Test mangle_names option

Import('env')

def set_mangling(type):
    def command(target, source, env):
        with open(str(source[0])) as src, open(str(target[0]), "w") as dst:
            dst.write("* mangle_names:{}\n".format(type))
            dst.write(src.read())
    return command

env.Command("strip_package.options", "with_package.options", set_mangling("M_STRIP_PACKAGE"))
env.Command("strip_package.proto", "with_package.proto", Copy("$TARGET", "$SOURCE"))
env.NanopbProto(["strip_package", "strip_package.options"])
env.Program(["test_strip_package.c", "strip_package.pb.c"])

env.Command("flatten.options", "with_package.options", set_mangling("M_FLATTEN"))
env.Command("flatten.proto", "with_package.proto", Copy("$TARGET", "$SOURCE"))
env.NanopbProto(["flatten", "flatten.options"])
env.Program(["test_flatten.c", "flatten.pb.c"])
